<link rel="stylesheet" href="assets/store/css/goods.css">
<link rel="stylesheet" href="assets/store/plugins/umeditor/themes/default/css/umeditor.css">
<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <form id="my-form" class="am-form tpl-form-line-form" method="post">
                    <div class="widget-body">
                        <fieldset>
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">基本信息</div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label"><?= $name ?>名称 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input name="user[nickName]" type="text" class="tpl-form-input" value="<?= $model['nickName'] ?>">
                                    <input type="hidden" id="user_id" value="<?= $model['user_id'] ?>">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">微信头像 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">
                                        <div class="uploader-list am-cf">
                                            <div class="file-item">
                                                <img src="<?= $model['avatarUrl'] ?>">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">等级 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <select name="level[level]" class="tpl-form-input">
                                        <option value="">请选择</option>
                                        <option value="1" <?= ($level["level"] == 1) ? "selected" : ""; ?>>初级</option>
                                        <option value="2" <?= ($level["level"] == 2) ? "selected" : ""; ?>>中级</option>
                                        <option value="3" <?= ($level["level"] == 3) ? "selected" : ""; ?>>高级</option>
                                    </select>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">服务费(<span style="color: red">元/小时</span>) </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input name="level[service_fee]" type="text" class="tpl-form-input" value="<?=$level['service_fee']?>">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">性别 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <select name="user[gender]" class="tpl-form-input">
                                        <option value="">请选择</option>
                                        <option value="1" <?= ($model["gender"] == "男") ? "selected" : ""; ?>>男</option>
                                        <option value="2" <?= ($model["gender"] == "男") ? "" : "selected"; ?>>女</option>
                                    </select>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">身高(<span style="color: red">单位：cm</span>) </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input name="user[height]" type="text" class="tpl-form-input" value="<?=$model['height']?>">
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">手机号码 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="user[phone]"
                                           value="<?= $model['phone'] ?>" required>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">个性签名 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="user[signature]"
                                           value="<?= $model['signature'] ?>" required>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">星座 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <input type="text" class="tpl-form-input" name="user[horoscope]"
                                           value="<?= $model['horoscope'] ?>" required>
                                </div>
                            </div>

                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label">服务员照片 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <div class="am-form-file">

                                        <div class="upload-file" data-name="wxapp[service_image]">
                                            <span id="uploadImage"></span>
                                            <!--<i class="am-icon-cloud-upload"></i> 上传图片-->
                                        </div>

                                        <div class="uploader-list am-cf" id="user_image">
                                            <?php foreach ($img as $key => $item): ?>
                                                <?php if ($item['is_delete']==0): ?>
                                                    <div class="file-item">
                                                        <img src="<?= $item['file_url'] . '/' . $item['file_name'] ?>">
                                                        <input type="hidden" name="images[]"
                                                               value="<?= $item['d_id'] ?>">
                                                        <i class="iconfont icon-shanchu file-item-delete"></i>
                                                    </div>
                                                <?php endif; ?>
                                            <?php endforeach; ?>
                                        </div>
                                    </div>
                                    <div class="help-block am-margin-top-sm">
                                        <small>尺寸750x750像素以上，大小2M以下 (可拖拽图片调整显示顺序 )</small>
                                    </div>
                                </div>
                            </div>


                            <!--<div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">是否在线 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <select name="user[isonline]" class="tpl-form-input">
                                        <option value="">请选择</option>
                                        <option value="Y" <? /*= ($model["isonline"] == "Y") ? "selected" : ""; */ ?>>在线
                                        </option>
                                        <option value="N" <? /*= ($model["isonline"] == "Y") ? "" : "selected"; */ ?>>离线
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="am-form-group">
                                <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">工作状态 </label>
                                <div class="am-u-sm-9 am-u-end">
                                    <select name="user[isworking]" class="tpl-form-input">
                                        <option value="">请选择</option>
                                        <option value="Y" <? /*= ($model["isworking"] == "Y") ? "selected" : ""; */ ?>>工作中
                                        </option>
                                        <option value="N" <? /*= ($model["isworking"] == "Y") ? "" : "selected"; */ ?>>空闲中
                                        </option>
                                    </select>
                                </div>
                            </div>
                       <div class="am-form-group">
                           <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">国家 </label>
                           <div class="am-u-sm-9 am-u-end">
                               <input type="text" class="tpl-form-input" name="user[country]"
                                      value="<? /*= $model['country'] */ ?>" required>
                           </div>
                       </div>
                       <div class="am-form-group">
                           <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">省份 </label>
                           <div class="am-u-sm-9 am-u-end">
                               <input type="text" class="tpl-form-input" name="user[province]"
                                      value="<? /*= $model['province'] */ ?>" required>
                           </div>
                       </div>
                       <div class="am-form-group">
                           <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">城市 </label>
                           <div class="am-u-sm-9 am-u-end">
                               <input type="text" class="tpl-form-input" name="user[city]"
                                      value="<? /*= $model['city'] */ ?>" required>
                           </div>
                       </div>
                            </div> <div class="am-form-group">
                           <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">出生年份 </label>
                           <div class="am-u-sm-9 am-u-end">
                               <input type="text" class="tpl-form-input" name="user[year]"
                                      value="<? /*= $model['year'] */ ?>" required>
                           </div>
                       </div>
                        <div class="am-form-group">
                           <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">出生月份 </label>
                           <div class="am-u-sm-9 am-u-end">
                               <input type="text" class="tpl-form-input" name="user[month]"
                                      value="<? /*= $model['month'] */ ?>" required>
                           </div>
                       </div>
                        <div class="am-form-group">
                           <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">出生日 </label>
                           <div class="am-u-sm-9 am-u-end">
                               <input type="text" class="tpl-form-input" name="user[day]"
                                      value="<? /*= $model['day'] */ ?>" required>
                           </div>
                       </div>

                       <div class="am-form-group">
                           <label class="am-u-sm-3 am-u-lg-2 am-form-label form-require">状态 </label>
                           <div class="am-u-sm-9 am-u-end">
                               <select name="user[status]" class="tpl-form-input">
                                   <option value="">请选择</option>
                                   <option value="0" <? /*=($model["status"]==0)?"selected":"";  */ ?>>未审核</option>
                                   <option value="1" <? /*=($model["status"]==1)?"selected":"";  */ ?>>提交审核</option>
                                   <option value="2" <? /*=($model["status"]==2)?"selected":"";  */ ?>>审核失败</option>
                                   <option value="3" <? /*=($model["status"]==3)?"selected":"";  */ ?>>审核成功</option>
                               </select>
                           </div>
                       </div>-->

                            <div class="am-form-group">
                                <div class="am-u-sm-9 am-u-sm-push-3 am-margin-top-lg">
                                    <button type="submit" class="j-submit am-btn am-btn-secondary">提交
                                    </button>
                                    <button type="button" onclick="window.history.back(-1);" class="am-btn am-btn-default">取消
                                    </button>
                                </div>
                            </div>

                        </fieldset>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="assets/store/js/ddsort.js"></script>
<script src="assets/store/plugins/umeditor/umeditor.config.js"></script>
<script src="assets/store/plugins/umeditor/umeditor.min.js"></script>
<script src="assets/store/js/goods.spec.js"></script>
<script>
    $(function () {

        // 选择图片
        /*$('.j-upload').selectImages({
            name: 'goods[images][]'
            , multiple: true
        });*/

        // 进行中动画索引
        var loadIndex = null;
        // 文件大小
        var maxSize = 2;
        var uploader = WebUploader.create({
            //是否允许重复的图片
            duplicate: true,
            // 选完文件后，是否自动上传
            auto: true,
            // swf文件路径
            // swf: '../JS/webuploader/Uploader.swf',
            // 文件接收服务端：
            server: STORE_URL + '/upload/user_image',
            pick: { id: "#uploadImage", innerHTML: "上传图片" }, // 选择文件的按钮。可选
            // 文件上传域的name
            fileVal: 'iFile',
            // 只允许选择图片文件。
            accept: {
                title: 'Images',
                extensions: 'gif,jpg,jpeg,bmp,png',
                mimeTypes: 'image/*'
            },
            //线程数
            threads: 1,
            //单个文件大小限制
            fileSingleSizeLimit: maxSize * 1024 * 1024,
            //上传文件数量限制
            fileNumLimit:10,
            //上传前不压缩
            compress:false,
            // 文件上传header扩展:
            headers: {
                'Accept': 'application/json, text/javascript, */*; q=0.01',
                'X-Requested-With': 'XMLHttpRequest'
            }
        });
        //  验证大小
        uploader.on('error', function (type) {
            switch (type){
                case "F_DUPLICATE":
                    alert('请不要重复选择文件！');
                    break;
                case "F_EXCEED_SIZE":
                    alert('文件大小不可超过' + maxSize + 'm 哦！换个小点的文件吧！');
                    break;
                case "Q_TYPE_DENIED":
                    alert('不支持的文件类型，请上传gif,jpg,jpeg,bmp,png类型的图片。');
                    break;
                default:
                    alert("出错了，上传失败")
            }
        });
        // 文件上传前触发,添加附带参数
        uploader.on('uploadBeforeSend', function (obj, data) {
            data.user_id = $("#user_id").val();
            data.isdefault = "N";
            data.group_id = -1;
        });
        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
        uploader.on('uploadSuccess', function (file, response) {
            if (response.code === 1) {
                $("#user_image").append(
                    '<div class="file-item">' +
                    '<img src="' + response.data.file_url + '/' + response.data.file_name + '">\n' +
                    '<input type="hidden" name="images[]"\n' +
                    'value="' + response.data.d_id + '">\n' +
                    '<i class="iconfont icon-shanchu file-item-delete"></i>' +
                    '</div>');
            } else {
                uploader.uploadError(file, response);
            }
        });
        // 监听文件上传失败
        uploader.on('uploadError', function (file, reason) {
            uploader.uploadError(file, reason);
        });
        // 文件上传失败回调函数
        uploader.uploadError = function (file, reason) {
            layer.msg(reason.msg, {anim: 6});
        };
        // 文件开始上传
        uploader.on('startUpload', function () {
            loadIndex = layer.load();
        });
        // 文件上传结束
        uploader.on('uploadFinished', function () {
            layer.close(loadIndex);
        });

        // 图片列表拖动
        $('.uploader-list').DDSort({
            target: '.file-item',
            delay: 100, // 延时处理，默认为 50 ms，防止手抖点击 A 链接无效
            floatStyle: {
                'border': '1px solid #ccc',
                'background-color': '#fff'
            }
        });


        /**
         * 表单验证提交
         * @type {*}
         */
        $('#my-form').superForm();

    });
</script>
